fix(memory): Fix memory leak for RecorderClass::m_crcInfo#2713
fix(memory): Fix memory leak for RecorderClass::m_crcInfo#2713Caball009 wants to merge 8 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/Common/Recorder.h | CRCInfo moved from .cpp file-local class to nested protected class; m_crcInfo changed from pointer to value member; default constructor added. |
| Generals/Code/GameEngine/Source/Common/Recorder.cpp | Old file-local CRCInfo class removed; CRCInfo method bodies moved to scoped RecorderClass::CRCInfo::; all m_crcInfo-> uses replaced with m_crcInfo.*; playbackFile() uses value assignment instead of NEW. |
| GeneralsMD/Code/GameEngine/Include/Common/Recorder.h | Identical structural change to the Generals header — CRCInfo nested in RecorderClass, m_crcInfo as value member. |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Mirror of the Generals .cpp change — old file-local CRCInfo removed, method bodies re-scoped, pointer access replaced with value access. |
Class Diagram
%%{init: {'theme': 'neutral'}}%%
classDiagram
class RecorderClass {
#CRCInfo m_crcInfo
+RecorderClass()
+~RecorderClass()
+playbackFile(filename) Bool
+handleCRCMessage(newCRC, playerIndex, fromPlayback)
+sawCRCMismatch() Bool
}
class CRCInfo {
#Bool m_sawCRCMismatch
#Bool m_skippedOne
#UnsignedInt m_localPlayer
#list~UnsignedInt~ m_data
+CRCInfo()
+CRCInfo(localPlayer, isMultiplayer)
+addCRC(val)
+readCRC() UnsignedInt
+GetQueueSize() int
+getLocalPlayer() UnsignedInt
+setSawCRCMismatch()
+sawCRCMismatch() Bool
}
RecorderClass *-- CRCInfo : nested class (value member)
note for RecorderClass "BEFORE: CRCInfo* m_crcInfo (heap via NEW, never deleted)\nAFTER: CRCInfo m_crcInfo (value member, auto-managed)"
Reviews (6): Last reviewed commit: "Tweaked 'CRCInfo' TSH comment." | Re-trigger Greptile
282478b to
c5e3079
Compare
xezon
left a comment
There was a problem hiding this comment.
Looking good. Needs replicate to Generals.
e99381e to
82efc2a
Compare
This avoids an unnecessary dynamic memory allocation and fixes a memory leak.
…aks to the latter.
|
Rebased to include the fix for the CI Replay checker. |
This PR fixes a memory leak for
RecorderClass::m_crcInfo. I decided to fix this one by not allocating theCRCInfoobject dynamically. This did require a larger change of moving the class to the header, though.See commits for clean diffs.
TODO: